import { resolve, join } from 'path';

import fs from 'fs';

let options: any = null;

const initFn = async () => {
  const isDev = process.env.NODE_ENV === 'development';

  const scriptPath = isDev
    ? resolve(`./config/data.json`)
    : join(
        process.resourcesPath,
        `app.asar.unpacked/plcChildProcess/config/data.json`
      );

  if (fs.existsSync(scriptPath)) {
    // console.log('exists');
    options = require(scriptPath) || null;
  };

  return options;
}

options = initFn();

export default options;
